﻿using DayuCode.Designer.Entity;
using DayuCode.Designer.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DayuCode.Designer.Service
{
    public class TemplatePageComponentHandler
    {
		private static string getBaseUrl(string methodName)
		{
			return AppInstance.ApiServer + "api/base/dayucode_templatePageComponentHandler/" + methodName;
		}

		public static List<TemplatePageComponent> getTemplatePageComponentsByFuncId(long funcId)
		{
			List<TemplatePageComponent> obj = QHttpClient.Post<List<TemplatePageComponent>>(getBaseUrl("getTemplatePageComponentsByFuncId"), new { funcId = funcId });
			return obj;
		}

		public static List<TemplatePageComponent> getTemplatePageComponents(long pagelayoutId)
		{
			List<TemplatePageComponent> obj = QHttpClient.Post<List<TemplatePageComponent>>(getBaseUrl("getTemplatePageComponents"), new { pagelayoutId = pagelayoutId });
			return obj;
		}

		public static TemplatePageComponent getTemplatePageComponent(long? id)
		{
			TemplatePageComponent obj = QHttpClient.Post<TemplatePageComponent>(getBaseUrl("getTemplatePageComponent"), new { id = id });
			return obj;
		}

		public static TemplatePageComponent saveTemplatePageComponent(TemplatePageComponent item)
		{
			TemplatePageComponent obj = QHttpClient.Post<TemplatePageComponent>(getBaseUrl("saveTemplatePageComponent"), new { item = item });
			return obj;
		}

		public static void deleteTemplatePageComponent(long pagelayoutId)
		{
			QHttpClient.Execute(getBaseUrl("deleteTemplatePageComponent"), new { pagelayoutId = pagelayoutId });
		}
	}
}
